package logic

import (
	"context"
	"meituan-waimai/meituanrpc/meituanrpc"

	"meituan-waimai/api/internal/svc"
	"meituan-waimai/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type OrderEvaluateLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewOrderEvaluateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *OrderEvaluateLogic {
	return &OrderEvaluateLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *OrderEvaluateLogic) OrderEvaluate(req *types.OrderEvaluateRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	evaluate, err := l.svcCtx.MeiTuanRpc.OrderEvaluate(l.ctx, &meituanrpc.OrderEvaluateRequest{
		UserId:  req.UserId,
		OrderId: req.OrderId,
		Content: req.Content,
		Star:    req.Star,
		Target:  req.Target,
	})
	if err != nil {
		return &types.Response{
			Code: -1,
			Msg:  "订单评价失败",
			Data: err.Error(),
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "订单评价成功",
		Data: evaluate,
	}, nil
}
